package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanhua.dubbo.mappers.FsrMapper;
import com.tanhua.model.domain.Fsr;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Random;

@DubboService
public class BlossmApiImpl implements BlossomApi{

    @Autowired
    private FsrMapper fsrMapper;

    @Override
    public Fsr findByUserId(Long userId) {
        LambdaQueryWrapper<Fsr> qw = new LambdaQueryWrapper<>();
        qw.eq(Fsr::getSendId,userId);
        return fsrMapper.selectOne(qw);
    }

    @Override
    public String save(Fsr fsr) {
        fsrMapper.insert(fsr);
        return null;
    }

    @Override
    public void update(Fsr fsr) {
        fsrMapper.updateById(fsr);
    }

    @Override
    public Fsr get() {
        return fsrMapper.rand();
    }
}
